/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mapbar.pay.listener;

import com.mapbar.pay.util.Util;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.log4j.Logger;

/**
 * Web application lifecycle listener.
 * @author fengbj
 */
public class UrlListener implements ServletContextListener {

    public Logger logger = Logger.getLogger(this.getClass());
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext  context = sce.getServletContext();

        Properties p = new Properties();
        try {
            p.load(new FileInputStream(new File(context.getRealPath("") + "//WEB-INF//classes//url.properties")));
            logger.info("加载接口配置url文件成功");
            Util.initUrlPros(p);
        } catch (Exception e) {
            logger.error("加载接口配置url文件失败，程序将无法正常运行 "+e.toString());
        }
       
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }
}
